home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c
- Subject: Re: Pointers to register
- Date: 22 Mar 1996 10:33:31 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4itvlr$5mi@sparcserver.lrz-muenchen.de>
- References: <1239@altheim.win-uk.net><18MAR199607594276@erich.triumf.ca> <1242@altheim.win-uk.net><314EC8E6.216E@ix.netcom.com> <1245@altheim.win-uk.net>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- broldham@altheim.win-uk.net (Brian R. Oldham) writes:
-
- >You are quite right. I checked in dos.h (BYTEREGS) and al, ah etc. are
- >all unsigned char. So today I went back to my program and changed the
- >declaration of scancode from pointer to int to a pointer to unsigned
- >char. Sure enough, my program compiled without complaint, but - guess
- >what - when I ran it in a main() the bloody system froze.
-
- >So back to my original question: why does the ostensibly incorrect
- >declaration:
-
- > *ptr = union_member_var;
-
- 1) This is not a declaration, and it is not an incorrect statement, because
- *ptr (in your case) is an int, and you _can_ assign an unsigned char
- to an int if an int can hold all possible values of an unsigned char.
- In this case, the result is well defined.
-
- >work, and the correct:
-
- > ptr = &union_member_var;
-
- If ptr is a pointer to int, and union_member_var is an unsigned char, this
- statement is _not_ correct, and if I remember right, someone told you
- that already.
-
- Why do you think that it is more correct to assign a pointer to an
- unsigned char to a variable that holds a pointer to an int than to
- assign an unsigned char to a variable that is an int.
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
- | ua302aa@sunmail.lrz-muenchen.de
-
-
-
-
-
-
-
-
-